# @Time : 2020/9/25 9:40
# @Author : Fioman 
# @Phone : 13149920693

import cv2 as cv
import numpy as np
from PIL import Image, ImageDraw, ImageFont


def put_chinese_to_image(image_path, start_point, text, color, size):
    pil_image = Image.open(image_path)
    font = ImageFont.truetype(r'C:\Users\wq\AppData\Local\Microsoft\Windows\Fonts\STXINGKA.TTF', size)
    # 生成画笔
    draw = ImageDraw.Draw(pil_image)
    draw.text(start_point, text, font=font, fill=color)
    new_img = cv.cvtColor(np.array(pil_image), cv.COLOR_RGB2BGR)
    cv.imwrite('new_love.jpg', new_img)
    return new_img

img = cv.imread("1.jpg",cv.IMREAD_COLOR)
print(img.shape)
newImg = np.zeros((1800,766,3),dtype=np.uint8)

newImg[200:1085,:766,:] = img
cv.imshow("newImg",newImg)
cv.imwrite("newImg.bmp",newImg)

# newImg = put_chinese_to_image("newImg.bmp",(480,900),"- 致奋斗的锤锤",(230,245,150),40)

cv.imshow("newImg",newImg)
cv.imwrite("newImg.bmp",newImg)

cv.waitKey(0)